Skip to content

Edit task.sql#195

Open
Dima-shima wants to merge 3 commits into
mate-academy:mainfrom
Dima-shima:main
Open

Edit task.sql#195
Dima-shima wants to merge 3 commits into
mate-academy:mainfrom
Dima-shima:main

Conversation

@Dima-shima

Copy link
Copy Markdown

No description provided.

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Summary

I am requesting changes because your schema does not yet match the required structure and this breaks the tests and core requirements. The primary key columns must be named exactly ID in all four tables; currently you use ProductsID, CustomersID, OrdersID, and OrderItemsID, which conflicts with the specification and causes lookups by ID to fail. Similarly, the foreign key columns must be named CustomerID in Orders, and OrderID/ProductID in OrderItems, but you currently use pluralized names like CustomersID, OrdersID, and ProductsID instead, which is why the tests report Unknown column 'CustomerID'. All foreign key constraints are also missing the required ON DELETE SET NULL clause (e.g. FOREIGN KEY (CustomerID) REFERENCES Customers(ID) ON DELETE SET NULL), so deletions will not behave as specified.

To fix this, rename all primary key columns to ID and adjust related foreign key columns to CustomerID, OrderID, and ProductID, then update each foreign key definition to include ON DELETE SET NULL and to reference the corrected column names. Your use of the correct database name, table presence, allowed data types, and AUTO_INCREMENT for primary keys is good, so once you align the names and foreign key behavior, your solution should fully meet the task requirements. Keep going—these are precise schema details, and getting them right is an important skill in database design.


✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨

Important

Fix the issues, commit the changes, and then re-request my review using the Re-request review button2 in the Reviewers tab.

Tip

If you have any comments about this review, please leave a message in the Add a comment section below and mention me with the @mateacademy-ai-mentor tag3.
I will read your message during my next review of your pull request. Please do not reply directly to my comments, as that feature is not supported yet.

Caution

Do not close the pull request until the review is complete. Closing it early can lead to unexpected behavior and disrupt the review process.

Footnotes

  1. Rate AI review example

  2. Re-request AI review example

  3. Add AI review comments example

Comment thread task.sql Outdated
CREATE DATABASE ShopDB;
USE ShopDB;
CREATE TABLE Products (
ProductsID INT AUTO_INCREMENT,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Products table is required to have a primary key column named exactly ID; using ProductsID instead violates the description and may break tests expecting the specified name.

Comment thread task.sql Outdated
PRIMARY KEY (ProductsID)
);
CREATE TABLE Customers (
CustomersID INT AUTO_INCREMENT,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similarly, the Customers table should have a primary key column named ID, not CustomersID, to match the exact required schema.

Comment thread task.sql Outdated
Comment on lines +20 to +21
OrdersID INT AUTO_INCREMENT,
CustomersID INT,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Orders table should use column names ID and CustomerID; here both OrdersID and CustomersID differ from the required names and will need to be renamed.

Comment thread task.sql Outdated
Comment on lines +28 to +30
OrderItemsID INT AUTO_INCREMENT,
OrdersID INT,
ProductsID INT,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The OrderItems table must use column names ID, OrderID, and ProductID; the current names (OrderItemsID, OrdersID, ProductsID) do not match the specification.

Comment thread task.sql Outdated
Comment on lines +24 to +25
FOREIGN KEY (CustomersID)
REFERENCES Customers(CustomersID)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All foreign keys in this task must include ON DELETE SET NULL as part of the constraint; this FK from Orders to Customers is missing that clause (see checklist items #10 and #11).

Comment thread task.sql Outdated
Comment on lines +32 to +35
FOREIGN KEY (OrdersID)
REFERENCES Orders(OrdersID),
FOREIGN KEY (ProductsID)
REFERENCES Products(ProductsID)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both foreign keys in this table (OrdersID and ProductsID) are also required to have ON DELETE SET NULL so that deleting related rows sets these references to NULL instead of failing or cascading deletes.

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Summary

I am requesting changes because there are still critical schema errors that will prevent MySQL from creating your tables successfully. You correctly declared ID INT AUTO_INCREMENT in all tables, but every PRIMARY KEY clause still points to non‑existent columns (ProductsID, CustomersID, OrdersID, OrderItemsID), so you must change each one to PRIMARY KEY (ID) to satisfy the requirement that the primary key column be named ID [CHECKLIST ITEM #10, #15]. Your foreign keys also reference the wrong parent columns: Orders currently references Customers(CustomerID), and OrderItems references Orders(OrderID) and Products(ProductID), but in each parent table the primary key is ID, so you need to reference Customers(ID), Orders(ID), and Products(ID) instead [CHECKLIST ITEMS #11#14, #16, #17]. In addition, the foreign key syntax order is off for MySQL; change each to the form FOREIGN KEY (CustomerID) REFERENCES Customers(ID) ON DELETE SET NULL (and similarly for the other FKs), with REFERENCES immediately after the column list.

Once you update all primary key definitions to use ID and adjust the foreign key REFERENCES targets and order, your script should execute cleanly and fully meet the task requirements. You’ve already done a solid job on table structure, column names, data types, and using ON DELETE SET NULL, so fixing these constraints will complete the solution.


✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨

Important

Fix the issues, commit the changes, and then re-request my review using the Re-request review button2 in the Reviewers tab.

Tip

If you have any comments about this review, please leave a message in the Add a comment section below and mention me with the @mateacademy-ai-mentor tag3.
I will read your message during my next review of your pull request. Please do not reply directly to my comments, as that feature is not supported yet.

Caution

Do not close the pull request until the review is complete. Closing it early can lead to unexpected behavior and disrupt the review process.

Footnotes

  1. Rate AI review example

  2. Re-request AI review example

  3. Add AI review comments example

Comment thread task.sql Outdated
Description VARCHAR(50),
Price INT,
WarehouseAmount INT,
PRIMARY KEY (ProductsID)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The primary key column for Products is named ID, but the constraint references ProductsID, which does not exist and violates checklist items #10 and #15. Update this to PRIMARY KEY (ID) so the actual ID column becomes the primary key.

Comment thread task.sql Outdated
LastName VARCHAR(50),
Email VARCHAR(50),
Address VARCHAR(50),
PRIMARY KEY (CustomersID)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similarly, the Customers primary key must be on the existing ID column. Using CustomersID here references a non‑existent column and breaks checklist items #10 and #15; change this to PRIMARY KEY (ID).

Comment thread task.sql Outdated
ID INT AUTO_INCREMENT,
CustomerID INT,
Date DATE,
PRIMARY KEY (OrdersID),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Orders table defines ID as the primary key, but this constraint references OrdersID, which does not exist. For checklist items #10 and #15, change this to PRIMARY KEY (ID).

Comment thread task.sql Outdated
Comment on lines +24 to +25
FOREIGN KEY (CustomerID) ON DELETE SET NULL
REFERENCES Customers(CustomerID)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This foreign key should reference the ID column in Customers, not CustomerID, which does not exist. Per checklist items #12, #16, and #17, adjust to something like FOREIGN KEY (CustomerID) REFERENCES Customers(ID) ON DELETE SET NULL (note also that REFERENCES should come before ON DELETE SET NULL in MySQL syntax).

Comment thread task.sql Outdated
ID INT AUTO_INCREMENT,
OrderID INT,
ProductID INT,
PRIMARY KEY (OrderItemsID),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The OrderItems primary key must be on the existing ID column; OrderItemsID does not exist, so this violates checklist items #10 and #15. Change this to PRIMARY KEY (ID).

Comment thread task.sql Outdated
Comment on lines +32 to +33
FOREIGN KEY (OrderID) ON DELETE SET NULL
REFERENCES Orders(OrderID),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This foreign key should reference Orders(ID) rather than Orders(OrderID), since the parent table’s primary key column is ID. For checklist items #13, #16, and #17, use FOREIGN KEY (OrderID) REFERENCES Orders(ID) ON DELETE SET NULL (with REFERENCES before ON DELETE).

Comment thread task.sql Outdated
Comment on lines +34 to +35
FOREIGN KEY (ProductID) ON DELETE SET NULL
REFERENCES Products(ProductID)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similarly, this foreign key should reference Products(ID) instead of Products(ProductID). To satisfy checklist items #14, #16, and #17, change this to FOREIGN KEY (ProductID) REFERENCES Products(ID) ON DELETE SET NULL.

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Summary

I am approving your solution because your ShopDB schema cleanly satisfies all the stated requirements and is valid MySQL DDL. You correctly create the database, select it, and define all four tables (Products, Customers, Orders, OrderItems) with the required columns and only the allowed data types (INT, DATE, VARCHAR(50)). Your primary keys are consistently implemented with ID INT AUTO_INCREMENT and PRIMARY KEY (ID), and your foreign keys correctly reference the parent tables with ON DELETE SET NULL as required. The foreign key relationships between OrdersCustomers and OrderItemsOrders/Products are all wired up correctly, so the relational structure matches a typical shop schema. There are no critical or minor issues that need fixing for this task, and the script should execute successfully as-is. Nice work implementing the constraints carefully and keeping the schema clear and consistent—this is a solid solution.


✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨

Footnotes

  1. Rate AI review example

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants